package com.qf.config;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/*
@author fu
@date 2022/3/2711:00
自定义的切面
*/
@Aspect
@Component
public class MyAspect {

    //切点表达式
    @Pointcut("execution(* *.*.service.impl.*.*(..))")
    public void pt() {}

    //环绕通知
    @Around("pt()")
    public Object myround(ProceedingJoinPoint proceedingJoinPoint) {
        Object obj = null;

        try {
            System.out.println("前置通知");
            obj = proceedingJoinPoint.proceed();
            System.out.println("后置通知");
            return obj;
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
            return null;
    }
}

